package com.behelpful.demo.search.listener;

import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.index.IndexResponse;
import org.springframework.stereotype.Component;

/**
 * ES 异步添加数据执行监听器
 *
 * @author Alay
 * @date 2021-04-20 19:49
 * @project behelpful
 */
@Slf4j
@Component
public class IndexListener implements ActionListener<IndexResponse> {
    @Override
    public void onResponse(IndexResponse response) {
        log.warn("index:{},异步新增数据成功,action:{},status:{}", response.getIndex(), response.getResult().name(), response.status().name());
    }

    @Override
    public void onFailure(Exception e) {
        log.error("异步添加数据失败,case:{},msg:{}", e.getCause(), e.getMessage());
    }
}